package com.aiju.listener;

import android.view.View;

import com.aiju.app.DataProviderManager;
import com.aiju.app.IDataProvider;
import com.aiju.common.network.INetState;
import com.aiju.utils.T;


/**
 * @author: 佐为
 * @date: 2017-02-08 09:39
 * @version: V1.0
 * @Description: 过滤网络异常的Click事件监听
 */
public abstract class OnNetClickListener implements View.OnClickListener {

    @Override
    public void onClick(View v) {
        IDataProvider dataProvider = DataProviderManager.getDataProvider();
        if (dataProvider == null) {
            return;
        }
        if (dataProvider.getNetType() != INetState.NETWORN_NONE) {
            onNetClick(v);
        } else {
            onNetError();
        }
    }

    public abstract void onNetClick(View view);

    protected void onNetError() {
        T.ToastNetError();
    }

}
